﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SmartSpace.Orgs;
using SmartSpace.Web;

namespace SmartSpace.WebApp.Modules.Orgs.Pages
{
    public partial class Employee_Add : SsTemplatePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void link_save_Click(object sender, EventArgs e)
        {
            Employee employee = new Employee();
            employee.Code = this.txt_Code.Text;
            employee.Id = Guid.NewGuid();
            employee.Account = this.txt_Account.Text;
            employee.NameCN = this.txt_NameCN.Text;
            employee.NameEN = this.txt_NameEN.Text;
            employee.Email = this.txt_Email.Text;
            employee.Phone = this.txt_Phone.Text;
            employee.Sex = Convert.ToInt32(this.txt_Sex.Text);
            employee.Birthday = Convert.ToDateTime(this.txt_Birthday.Text);
            employee.IdCardNo = this.txt_IdCardNo.Text;

            OrgsService service = new OrgsService();
            ServiceResult result = service.SaveEmployee(employee);
            if (result.IsSuccess)
            {
                Response.Redirect("Employee-List.aspx");
            }
        }

        protected void link_back_Click(object sender, EventArgs e)
        {
            Response.Redirect("Employee-List.aspx");
        }
    }
}